import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export interface SearchDeviceT {
  page: number;
  pageSize: number;
  ip: string;
  hostname: string;
}

export interface MiaoClientT {
  deviceID: string;
  mainBoardSerial: string;
  activeMAC: string;
  ip: string;
  hostname: string;
  createdAt: string;
  isOverlap: boolean;
}

export interface DeviceDetailT {
  client: MiaoClientT;
}

export interface MiaoWinPageResult {
  list: MiaoClientT[];
  total: number;
}

export const getMiaoWinPage = (data: SearchDeviceT) => {
  return http.request<MiaoWinPageResult>("get", baseUrlApi("miao/win/page"), {
    data
  });
};

export interface SearchWinDetailT {
  id: number;
  infoType: string;
}

export const getMiaoWinDetail = (data: SearchWinDetailT) => {
  return http.request("get", baseUrlApi("miao/win/detail"), { data });
};

export interface MiaoInstructT {
  deviceId: string;
  code: number;
  body;
}

export const sendMiaoInstruct = (data: MiaoInstructT) => {
  return http.request("post", baseUrlApi("miao/sendInstruct"), { data });
};

export const getIdpLog = (deviceID: String, logType: String) => {
  return http.request<any>("get", baseUrlApi("miao/win/getLog"), {
    params: { logType: logType, deviceId: deviceID }
  });
};
